package com.kly.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kly.api.ai.model.CreateImageOutPaintingResponse;
import com.kly.api.imagesearch.model.SoImageSearchResult;
import com.kly.common.PageRequest;
import com.kly.domain.dto.pircture.*;
import com.kly.domain.dto.user.TopThumbUserRequest;
import com.kly.domain.entity.ImageExpansion;
import com.kly.domain.entity.Picture;
import com.kly.domain.entity.User;
import com.kly.domain.vo.PictureTagCategory;
import com.kly.domain.vo.PictureVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
* @author admin
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-03-03 20:07:13
*/
public interface PictureService extends IService<Picture> {



    /**
     * 保存图片
     * @param inputSource
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO savePicture(Object inputSource, PictureUploadRequest pictureUploadRequest, User loginUser);

    /**
     * 获取查询的 queryWrapper
     * @param pictureQueryRequest 图片请求类
     * @return 可用来查询的 queryWrapper
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);



    /**
     * 获取单个图片的 VO 对象
     * @param picture picture 对象
     * @param request request 请求
     * @return 对应图片的 VO
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);


    /**
     * 校验图片参数
     */
    void validatePictureInfo(Picture picture);


    /**
     * 返回图片的 VO 对象 page
     */
    Page<PictureVO> listPictureVOByPage(Page<Picture> page);


    /**
     * 审核图片
     * @param pictureReviewRequest
     * @param loginUser
     * @return
     */
    boolean reviewPicture(PictureReviewRequest pictureReviewRequest, User loginUser);


    /**
     * 填充审核信息
     *
     * @param picture
     * @param loginUser
     */
    void fillReviewInfo(Picture picture, User loginUser);


    /**
     * 网络批量获取图片 爬虫
     */
    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser);


    /**
     * 删除图片 cos
     */
    void deletePictureCos(Picture picture);


    /**
     * 校验图片权限
     * @param picture
     * @param loginUser
     */
    void checkSpaceAuth(Picture picture, User loginUser);


    /**
     * 根据颜色搜索图片
     * @param searchPictureByColorRequest
     * @param loginUser
     * @return
     */
    List<PictureVO> searchPictureByColor(SearchPictureByColorRequest searchPictureByColorRequest, User loginUser);


    /**
     * 批量修改图片
     * @param pictureEditBatchRequest
     * @param loginUser
     * @return
     */
    boolean editPictureBatch(PictureEditBatchRequest pictureEditBatchRequest, User loginUser);


    /**
     * 创建图片外绘任务
     * @param createPictureOutPaintingTaskRequest
     * @param loginUser
     * @return
     */
    CreateImageOutPaintingResponse createImageOutPainting(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);


    /**
     * 创建图片外绘任务 2
     * @param createPictureOutPaintingTaskRequest
     * @return
     */
    CreateImageOutPaintingResponse createImageOutPainting(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest);

    /**
     * 点赞图片
     * @param pictureThumbRequest
     * @param loginUser
     * @return
     */
    boolean doThumbPicture(PictureThumbRequest pictureThumbRequest, User loginUser);

    /**
     * 设置是否点赞
     *
     * @param pictureVO
     * @param userId
     */
    void setThumb(PictureVO pictureVO, Long userId);

    /**
     * 获取点赞用户
     *
     * @param topThumbUserRequest@return
     */
    List<User> getTop5ThumbUserByPictureId(TopThumbUserRequest topThumbUserRequest);



    /**
     * 删除图片
     * @param id
     * @param loginUser
     */
    boolean deletePicture(Long id, User loginUser);


    /**
     * 搜索图片
     *
     * @param pictureSearchRequest
     * @param loginUser
     * @return
     */
    List<String> searchLikePicture(PictureSearchRequest pictureSearchRequest, User loginUser);

    /**
     * 根据图片id获取图片
     * @param id
     * @return
     */
    Picture getPictureById(Long id);

    Picture getPictureByIdByLogic(Long id);

    /**
     * 缓存预热
     * @param id
     * @param ttl
     */
    void savePictureWithLogicTime(Long id, Integer ttl);

    /**
     * 根据图片url搜索图片
     *
     * @return
     */
    Page<SoImageSearchResult> searchSimilarImageByUrl(SearchPictureByPictureRequest searchPictureByPictureRequest);

    /**
     * 获取图片标签分类
     * @return
     */
    PictureTagCategory listPictureTagCategory();


    /**
     * 缓存预热 查询分页热门数据
     */
    Map<String, Page<PictureVO>> listPictureVOByPage();

    /**
     * 获取图片外扩列表
     * @param pageRequest
     * @return
     */
    Page<ImageExpansion> getExpandedImageList(PageRequest pageRequest);
}
